#!/bin/bash

source src/conf/config.conf

touch pxelinux.cfg/fedora.cfg
echo " Downloading Fedora Core ..."

f_url=http://fedora.dcc.fc.up.pt/linux/releases/$fedora_ver/Fedora/$fedora_arch/os/images/pxeboot/

cd $tftp_dir
    for ARCH in i386 x86_64; do
        mkdir -p "fedora/${ARCH}"

wget -q -c $f_url/vmlinuz && mv vmlinuz fedora/$fedora_arch/
wget -q -c $f_url/initrd.img && mv initrd.img fedora/$fedora_arch/


 done


cat >> pxelinux.cfg/linux << EOF

DEFAULT install
PROMPT 1
TIMEOUT 50 
menu title Fedora Installer
menu include pxelinux.cfg/graphics.conf
MENU BACKGROUND pxelinux.cfg/background.png


MENU BEGIN oses-submenu
 LABEL Previous
        MENU LABEL Previous Menu
        TEXT HELP
        Return to previous menu
        ENDTEXT
        MENU EXIT
 MENU TITLE Install Fedora Core
MENU INCLUDE pxelinux.cfg/fedora.cfg

MENU END


EOF


    for ARCH in i386 x86_64; do
	echo "menu include pxelinux.cfg/graphics.conf"
echo "MENU BACKGROUND pxelinux.cfg/background.png"

        echo "label Install Fedora ${ARCH}"
        echo "      menu label Fedora ${ARCH}"
        echo "      kernel LINUX/fedora/${ARCH}/vmlinuz"
        echo "      append initrd=LINUX/fedora/${ARCH}/initrd.img quiet"
   
 echo " "
	echo " TEXT HELP"
       echo "  Install Fedora Core Linux ${ARCH}"
        echo " ENDTEXT"

done >> pxelinux.cfg/fedora.cfg
 
yes | cp -Rv fedora/* LINUX/fedora/

sleep 3
mv fedora/ tars/

